SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE [dbo].[SP_TASALD_CORP_Q21]    
/*--------------------------------------------------------------------------*/    
/*--- Sistema        : OFICONT                                 ---*/    
/*--- Programa       : Proceso de Consolidaci>n de Empresas   ---*/    
/*--- Nombre         : SP_TASALD_CORP_Q21                 ---*/    
/*--- Nombre Orig    : SP_TASALD_CNTB_CORP_Q21                ---*/    
/*--- Cliente        : EPENSA      ---*/    
/*--- Desarrollado   : Franco Gamboni Koifman                 ---*/    
/*--- Fecha          : 22/03/1997                             ---*/    
/*--- Update         : 09/03/1998                            ---*/    
/*-------------------------------------------------------------------------*/    
/*--- Modificado 1   : 08/08/1998                            ---*/    
/*--- Base de Datos  : ORACLE v. 8                       ---*/    
/*--- Comentario     : Elimina informaci>n de la tabla de     ---*/    
/*---         saldos corporativa y copia plan de     ---*/    
/*---         cuentas corporativo a la tabla de      ---*/    
/*---         saldos corporativos              ---*/    
/*-------------------------------------------------------------------------*/    
/*-------------------------------------------------------------------------*/    
/*--- Modificado 2  : Yessica Morales Taipe    ---*/    
/*--- Fecha     : 26/12/2000     ---*/    
/*--- Detalle      : Migraci?n a BD SQl 7.0    ---*/    
/*-------------------------------------------------------------------------*/    
/*-------------------------------------------------------------------------*/    
/*--- Modificado 3  : percy garcia                                      ---*/    
/*--- Fecha         : 05/06/2004                                        ---*/    
/*--- Detalle       : usuario creacion y modif                          ---*/    
/*-------------------------------------------------------------------------*/    
/*-------------------------------------------------------------------------*/    
/*--- Modificado 4  : percy garcia                                      ---*/    
/*--- Fecha         : 24/11/2004                                        ---*/    
/*--- Detalle       : SE AUMENTO EN EL INSERT EL CAMPO PR_DATO ---*/    
/*-------------------------------------------------------------------------*/    
/*-------------------------------------------------------------------------*/    
/*--- Drop Procedure SP_TASALD_CORP_Q21;                    ---*/    
/*--- GRANT ALL ON SP_TASALD_CORP_Q21 To PUBLIC;    ---*/    
/*--- SP_TASALD_CNTB_Q21 2000, 1                    ---*/    
/*-------------------------------------------------------------------------*/    
 @ISCO_USUA          TD_VC_008,
 @IDFE_USUA          TD_DT_001,
 @INNU_ANNO TD_IN_004_ANNO,    
 @INNU_MESE TD_IN_002_MESE    
    
As    
 Declare                                 
  @VNNU_MES_1   TD_IN_001,    
  @VNNV_INFO_CNTA INT,    
  @VSPR_DATO TD_VC_020  
    
 Begin    
  Select @VNNV_INFO_CNTA = NV_INFO_CNTA    
  From   TMCORP    
    
  Delete TASALD_CORP     
  Where NU_ANNO =  @INNU_ANNO    
  And  NU_MESE <= @INNU_MESE    
    
  SELECT @VNNU_MES_1 = 0    
    
  While @VNNU_MES_1 <= @INNU_MESE    
   Begin    
     Select @VSPR_DATO  = replicate('0',@VNNU_MES_1) + '1' + replicate('0',20-(@VNNU_MES_1+1))    
  Insert Into TASALD_CORP(NU_ANNO, NU_MESE, CO_CNTA_CORP, TI_AUXI_CORP,     
    CO_AUXI_CORP, IM_CARG_MESE, IM_ABON_MESE, PR_DATO, CO_USUA_MODI, FE_USUA_MODI, CO_USUA_CREA, FE_USUA_CREA)    
 Select @INNU_ANNO, @VNNU_MES_1, CO_CNTA_CORP, NULL, NULL, 0.00, 0.00, @VSPR_DATO, @ISCO_USUA , @IDFE_USUA, @ISCO_USUA, @IDFE_USUA    
   From TMPLAN_CORP    
  WHERE Datalength(CO_CNTA_CORP) = @VNNV_INFO_CNTA    
    
 Select @VNNU_MES_1 = @VNNU_MES_1 + 1    
   End    
 End    
-----------------------------------  FIN  --------------------------------------


GO
